﻿using ActivateYourGlutes.Infrastructure;
using ActivateYourGlutes.Model.Contracts;

namespace ActivateYourGlutes.Model.Providers
{
    public class LocalisationProvider : ILocalisationProvider
    {
        private UserLocaleSettings _settings;

        #region ILocalisationProvider Members

        /// <summary>
        /// Sets the current locale settings in the provider
        /// </summary>
        public void SetUserLocaleSettings(UserLocaleSettings settings)
        {
            _settings = settings;
        }

        /// <summary>
        /// The current unit of length for the user
        /// </summary>
        public UnitOfLength UnitOfLength
        {
            get
            {
                if (_settings == null)
                    throw new LocalisationException(
                        "User locale settings have not been set of the localisation provider");
                return _settings.UnitOfLength;
            }
        }

        /// <summary>
        /// The current unit of weight for the user
        /// </summary>
        public UnitOfWeight UnitOfWeight
        {
            get
            {
                if (_settings == null)
                    throw new LocalisationException(
                        "User locale settings have not been set of the localisation provider");
                return _settings.UnitOfWeight;
            }
        }

        #endregion
    }
}